package dao;

import java.util.List;

import entity.RoomType;

public class RoomTypeDao {

	public List<RoomType> select() {
		return DbHepler.executeQuery("select * from RoomType", RoomType.class);
	}
	
	public int insert(RoomType model) {
		return DbHepler.executeUpdate("insert into RoomType (name,price,marks) values(?,?,?)", 
				model.getName(),
				model.getPrice(),
				model.getMarks());
	}
	
	public int update(RoomType model) {
		return DbHepler.executeUpdate("update RoomType set name=?,price=?,marks=? where id=?",model.getName(),model.getPrice(),model.getMarks(),model.getId());
	}
	
	public int delete(int id) {
		return DbHepler.executeUpdate("delete from RoomType where id=?", id);
	}
	
	public RoomType getbyid(int id) {
		List<RoomType> list=DbHepler.executeQuery("select * from RoomType where id=?", RoomType.class,id);
		return list.get(0);
	}
	
}
